package com.stt.design.command.impl;

import com.stt.base.model.Device;
import com.stt.design.command.DeviceCommand;
import lombok.RequiredArgsConstructor;

/**
 * 设备开关命令
 * 封装设备开关操作
 */
@RequiredArgsConstructor
public class DeviceSwitchCommand implements DeviceCommand {
    private final Device device;
    private final boolean targetStatus;
    private final boolean previousStatus;
    
    @Override
    public void execute() {
        device.setStatus(targetStatus);
    }
    
    @Override
    public void undo() {
        device.setStatus(previousStatus);
    }
    
    @Override
    public String getDescription() {
        return String.format("%s 设备 %s", 
            device.getName(), 
            targetStatus ? "开启" : "关闭"
        );
    }
} 